Skip to content

Im calc rust#88

Merged
lispandfound merged 16 commits intopegasusfrom
im_calc_rust
Feb 23, 2026
Merged

Im calc rust#88
lispandfound merged 16 commits intopegasusfrom
im_calc_rust

Conversation

@lispandfound
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 10, 2026 21:59
@gemini-code-assist
Copy link

Summary of Changes

Hello @lispandfound, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the intensity measure (IM) calculation workflow by introducing explicit control over parallel processing and refining data handling. It also optimizes the SRF file generation process for single-source scenarios, improving efficiency by avoiding unnecessary operations.

Highlights

  • IM Calculation Parallelism: Introduced a 'cores' parameter in 'im_calc.py' to explicitly control the number of parallel processes for intensity measure calculations, replacing the implicit 'numexpr' thread management.
  • IM Calculation Parameter Updates: Updated various intensity measure functions (PGA, PGV, CAV, AI, Ds575, Ds595, pSA, FAS) to utilize the new 'cores' parameter. The 'pSA' calculation also saw a change in 'periods' data type to 'float64' and the addition of a 'step' parameter.
  • Waveform Handling Simplification: Streamlined waveform data preparation in 'im_calc.py' by removing an explicit transposition step, indicating that downstream IM functions now expect the original waveform format.
  • SRF Generation Optimization: Optimized the SRF file generation process in 'realisation_to_srf.py' by directly moving single-source SRF files instead of performing a redundant stitching operation.
Changelog
  • workflow/scripts/im_calc.py
    • Removed the 'numexpr' library dependency.
    • Added a 'cores' command-line option to specify the number of parallel processes for IM calculations.
    • Configured various IM functions (PGA, PGV, CAV, AI, Ds575, Ds595, pSA, FAS) to accept and utilize the new 'cores' parameter.
    • Updated the 'pseudo_spectral_acceleration' (pSA) calculation to use 'float64' for periods and introduced a 'step' parameter.
    • Simplified waveform data preparation by removing an explicit transposition, aligning with the expected input format of IM functions.
  • workflow/scripts/realisation_to_srf.py
    • Modified the SRF generation logic to directly move the SRF file for single source geometries, bypassing the 'stitch_srf_files' function when not needed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable improvements. In im_calc.py, it adds configurable parallel processing for intensity measure calculations, removes the numexpr dependency, and refactors waveform handling to be more direct, which is a great enhancement. The changes in realisation_to_srf.py correctly handle the case for a single source geometry, avoiding unnecessary processing. My review includes one suggestion to replace a magic number with a named constant to improve code clarity and maintainability.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the SRF generation and IM calculation scripts to better handle single-fault SRF outputs and to make IM computation configurable for parallel execution.

Changes:

  • Avoids SRF “stitching” when there is only a single source geometry by moving/renaming the generated SRF instead.
  • Adds a --cores option to im-calc and threads this through to IM calculation functions.
  • Adjusts IM calculation input preparation (dtype and array handling) and PSA period dtype.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
workflow/scripts/realisation_to_srf.py Skips stitching for single-geometry ruptures and moves the generated SRF to the final expected filename.
workflow/scripts/im_calc.py Adds configurable core count and updates how waveform arrays/parameters are prepared and passed into IM functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

joelridden
joelridden previously approved these changes Feb 22, 2026
Copy link
Contributor

@AndrewRidden-Harper AndrewRidden-Harper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion for a docstring but otherwise, looks great

Co-authored-by: AndrewRidden-Harper <52001209+AndrewRidden-Harper@users.noreply.github.com>
@lispandfound lispandfound merged commit ca3b636 into pegasus Feb 23, 2026
7 checks passed
@lispandfound lispandfound deleted the im_calc_rust branch February 23, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants